package com.ethanzzh.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class StuServlet03 extends BaseServlet {
    public String addStu(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("执行服务端添加功能");
        //转发到success.jsp
//        req.getRequestDispatcher("/success.jsp").forward(req, resp);
        return "/success.jsp";

    }

    public String delStu(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("执行服务端删除功能");
        //转发到success.jsp
//        req.getRequestDispatcher("/success.jsp").forward(req, resp);
        return "/success.jsp";
    }

    public String updateStu(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("执行服务端更新功能");
        //由于修改学生这个请求是通过Ajax实现的,是不需要进行转发的，直接响应数据即可
        resp.getWriter().print("updateStuOK");
        return null;
    }

    public String findStu(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("执行服务端查找功能");
        //转发到success.jsp
//        req.getRequestDispatcher("/success.jsp").forward(req, resp);
        return "/success.jsp";
    }

}
